package com.tanhua.dubbo.api;

import com.tanhua.dubbo.mappers.SoulReportMapper;
import com.tanhua.model.testpaper.SoulReport;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Slf4j
@DubboService
class SoulReportApiImpl implements SoulReportApi {
    @Autowired
    private SoulReportMapper soulReportMapper;

    @Override
    public void save(SoulReport soulReport) {
        log.info("报告{}", soulReport.toString());
        soulReportMapper.insert(soulReport);
    }

    @Override
    public String findByObject(SoulReport soulReport) {
        log.info("baogao{}", soulReport);
        SoulReport soulReports = soulReportMapper.selectOneId(soulReport.getUserId(), soulReport.getCreated());
        log.info("zczczczc-----{}", soulReports);
        return soulReports.getId().toString();
    }

    @Override
    public List<SoulReport> findByUserId(Long userId) {

       return soulReportMapper.selectByUserIdList(userId);
    }

    @Override
    public SoulReport findById(Long id) {
        return   soulReportMapper.selectById(id);

    }

    @Override
    public List<Long> findbyAppraiseId(Long appraiseId, Long paperId, Long userId) {
        return soulReportMapper.findSimilarUsers(appraiseId,paperId,userId);
    }
}
